package org.example.spi;

import java.util.*;

/**
 * @Author : 叶荻风
 * @create : 2024/6/7 11:40
 * SPI
 */
public class PluginFactory {
    public void installPlugin(){
        Map context = new HashMap();
        context.put("_beans",new ArrayList<>());
        context.put("_version","1.0.0");
        context.put("_aspect",new HashMap<>());

        //扫描classpath下所有plugin 的实现类

        ServiceLoader<Plugin> loader = ServiceLoader.load(Plugin.class);
        for (Plugin next : loader) {
            next.install(context);
        }

    }

    public static void main(String[] args) {
        new PluginFactory().installPlugin();
    }
}
